package com.example.forum.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

@Data
@Getter
@Setter
public class Article {
    private Long id;

    private Long boardId;

    private Long userId;

    private String title;

    //访问次数
    @JsonInclude(JsonInclude.Include.ALWAYS)
    private Integer visitCount;

    //回复次数
    @JsonInclude(JsonInclude.Include.ALWAYS)
    private Integer replyCount;

    //点赞次数
    @JsonInclude(JsonInclude.Include.ALWAYS)
    private Integer likeCount;


    private Byte state;

    private Byte deleteState;

    private Date createTime;

    private Date updateTime;

    private String content;

    // flag 判断文章作者 和登录用户是否是同一个人
    @ApiModelProperty("是否是作者")
    private Boolean own;

    //关联对象
    private User user;
    private Board board;

    //判断登录用户id 与 帖子作者id 是否一致
    public static boolean judge(Long userId, Long articleId) {
        if (userId.equals(articleId)) {
            return true;
        } else {
            return false;
        }
    }
}